package com.imy.accessibility.dialog;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.imy.accessibility.R;
import com.imy.accessibility.bean.CustomNode;
import com.imy.accessibility.bean.NodeItem;
import com.imy.common.base.BaseDialog;
import com.imy.common.util.ALog;

import java.util.ArrayList;
import java.util.List;

public class NodeInfoDialog extends BaseDialog {
    private ListView mListView;

    public NodeInfoDialog(AppCompatActivity activity) {
        super(activity);

    }



    @Override
    protected int getLayoutId() {
        return R.layout.dialog_node_info;
    }

    @Override
    protected void init(View view) {
        super.init(view);
        mListView = view.findViewById(R.id.list_view);
    }
    public void show(CustomNode customNode){
        List<NodeItem> list=new ArrayList<>();

        list.add(new NodeItem(getRes(R.string.bounds_in_screen),customNode.mBoundsInScreen.toString()));
        list.add(new NodeItem(getRes(R.string.bounds_in_parent),customNode.mBoundsInParent.toString()));
        list.add(new NodeItem(getRes(R.string.package_name),customNode.mPackageName.toString()));
        list.add(new NodeItem(getRes(R.string.class_name),customNode.mClassName.toString()));
        list.add(new NodeItem(getRes(R.string.res_id),customNode.mViewIdResourceName));
        list.add(new NodeItem(getRes(R.string.can_clicked),customNode.clickable+""));
        list.add(new NodeItem(getRes(R.string.can_long_clicked),customNode.longClickable+""));
        list.add(new NodeItem(getRes(R.string.text),customNode.mText+""));
        list.add(new NodeItem(getRes(R.string.hint_text),customNode.mHintText+""));
        list.add(new NodeItem(getRes(R.string.content_des),customNode.mContentDescription+""));
        NodeInfoAdapter nodeInfoAdapter = new NodeInfoAdapter(mActivity,list);
        mListView.setAdapter(nodeInfoAdapter);
    }

    private String getRes(int res){
       return mActivity.getResources().getString(res);
    }
}
